
/*
 * Copyright 2002-2022 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/*
 *版权所有2002-2022原作者。
 *
 *根据Apache许可证2.0版（“许可证”）获得许可；
 *除非符合许可证，否则不得使用此文件。
 *您可以在以下地址获取许可证副本：
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 *除非适用法律要求或书面同意，软件
 *根据许可证分发的内容是按“原样”分发的，
 *无任何明示或暗示的保证或条件。
 *有关管理权限和
 *许可证下的限制。
 */

package org.springframework.beans;

import java.util.Map;

import org.springframework.core.convert.TypeDescriptor;
import org.springframework.lang.Nullable;

/**
 * Common interface for classes that can access named properties
 * (such as bean properties of an object or fields in an object).
 *
 * <p>Serves as base interface for {@link BeanWrapper}.
 *
 * @author Juergen Hoeller
 * @since 1.1
 * @see BeanWrapper
 * @see PropertyAccessorFactory#forBeanPropertyAccess
 * @see PropertyAccessorFactory#forDirectFieldAccess
 */
/**
 *可访问命名财产的类的通用接口
 *（例如对象的bean财产或对象中的字段）。
 *
 *＜p＞用作｛@link BeanWrapper｝的基本接口。
 *
 *@作者Juergen Hoeller
 *@自1.1
 *@参见BeanWrapper
 *@see PropertyAccessorFactory#for BeanPropertyAccess
 *@see PropertyAccessorFactory#for DirectFieldAccess
 */
public interface PropertyAccessor {

	/**
	 * Path separator for nested properties.
	 * Follows normal Java conventions: getFoo().getBar() would be "foo.bar".
	 */
	/**
	 *嵌套财产的路径分隔符。
	 *遵循常规Java约定：getFoo（）.getBar（）将是“foo.bar”。
	 */
	String NESTED_PROPERTY_SEPARATOR = ".";

	/**
	 * Path separator for nested properties.
	 * Follows normal Java conventions: getFoo().getBar() would be "foo.bar".
	 */
	/**
	 *嵌套财产的路径分隔符。
	 *遵循常规Java约定：getFoo（）.getBar（）将是“foo.bar”。
	 */
	char NESTED_PROPERTY_SEPARATOR_CHAR = '.';

	/**
	 * Marker that indicates the start of a property key for an
	 * indexed or mapped property like "person.addresses[0]".
	 */
	/**
	 *标记，指示
	 *索引或映射属性，如“person.addresss[0]”。
	 */
	String PROPERTY_KEY_PREFIX = "[";

	/**
	 * Marker that indicates the start of a property key for an
	 * indexed or mapped property like "person.addresses[0]".
	 */
	/**
	 *标记，指示
	 *索引或映射属性，如“person.addresss[0]”。
	 */
	char PROPERTY_KEY_PREFIX_CHAR = '[';

	/**
	 * Marker that indicates the end of a property key for an
	 * indexed or mapped property like "person.addresses[0]".
	 */
	/**
	 *指示属性键结尾的标记
	 *索引或映射属性，如“person.addresss[0]”。
	 */
	String PROPERTY_KEY_SUFFIX = "]";

	/**
	 * Marker that indicates the end of a property key for an
	 * indexed or mapped property like "person.addresses[0]".
	 */
	/**
	 *指示属性键结尾的标记
	 *索引或映射属性，如“person.addresss[0]”。
	 */
	char PROPERTY_KEY_SUFFIX_CHAR = ']';


	/**
	 * Determine whether the specified property is readable.
	 * <p>Returns {@code false} if the property doesn't exist.
	 * @param propertyName the property to check
	 * (may be a nested path and/or an indexed/mapped property)
	 * @return whether the property is readable
	 */
	/**
	 *确定指定的属性是否可读。
	 *＜p＞如果属性不存在，则返回｛@code false｝。
	 *@param propertyName要检查的属性
	 *（可以是嵌套路径和/或索引/映射属性）
	 *@return属性是否可读
	 */
	boolean isReadableProperty(String propertyName);

	/**
	 * Determine whether the specified property is writable.
	 * <p>Returns {@code false} if the property doesn't exist.
	 * @param propertyName the property to check
	 * (may be a nested path and/or an indexed/mapped property)
	 * @return whether the property is writable
	 */
	/**
	 *确定指定的属性是否可写。
	 *＜p＞如果属性不存在，则返回｛@code false｝。
	 *@param propertyName要检查的属性
	 *（可以是嵌套路径和/或索引/映射属性）
	 *@return属性是否可写
	 */
	boolean isWritableProperty(String propertyName);

	/**
	 * Determine the property type for the specified property,
	 * either checking the property descriptor or checking the value
	 * in case of an indexed or mapped element.
	 * @param propertyName the property to check
	 * (may be a nested path and/or an indexed/mapped property)
	 * @return the property type for the particular property,
	 * or {@code null} if not determinable
	 * @throws PropertyAccessException if the property was valid but the
	 * accessor method failed
	 */
	/**
	 *确定指定属性的属性类型，
	 *检查属性描述符或检查值
	 *在索引或映射元素的情况下。
	 *@param propertyName要检查的属性
	 *（可以是嵌套路径和/或索引/映射属性）
	 *@return特定属性的属性类型，
	 *或｛@code null｝（如果不可确定）
	 *如果属性有效但
	 *访问器方法失败
	 */
	@Nullable
	Class<?> getPropertyType(String propertyName) throws BeansException;

	/**
	 * Return a type descriptor for the specified property:
	 * preferably from the read method, falling back to the write method.
	 * @param propertyName the property to check
	 * (may be a nested path and/or an indexed/mapped property)
	 * @return the property type for the particular property,
	 * or {@code null} if not determinable
	 * @throws PropertyAccessException if the property was valid but the
	 * accessor method failed
	 */
	/**
	 *返回指定属性的类型描述符：
	 *优选地从读取方法返回到写入方法。
	 *@param propertyName要检查的属性
	 *（可以是嵌套路径和/或索引/映射属性）
	 *@return特定属性的属性类型，
	 *或｛@code null｝（如果不可确定）
	 *如果属性有效但
	 *访问器方法失败
	 */
	@Nullable
	TypeDescriptor getPropertyTypeDescriptor(String propertyName) throws BeansException;

	/**
	 * Get the current value of the specified property.
	 * @param propertyName the name of the property to get the value of
	 * (may be a nested path and/or an indexed/mapped property)
	 * @return the value of the property
	 * @throws InvalidPropertyException if there is no such property or
	 * if the property isn't readable
	 * @throws PropertyAccessException if the property was valid but the
	 * accessor method failed
	 */
	/**
	 *获取指定属性的当前值。
	 *@param propertyName要获取值的属性的名称
	 *（可以是嵌套路径和/或索引/映射属性）
	 *@返回属性的值
	 *如果没有此类属性或
	 *如果属性不可读
	 *如果属性有效但
	 *访问器方法失败
	 */
	@Nullable
	Object getPropertyValue(String propertyName) throws BeansException;

	/**
	 * Set the specified value as current property value.
	 * @param propertyName the name of the property to set the value of
	 * (may be a nested path and/or an indexed/mapped property)
	 * @param value the new value
	 * @throws InvalidPropertyException if there is no such property or
	 * if the property isn't writable
	 * @throws PropertyAccessException if the property was valid but the
	 * accessor method failed or a type mismatch occurred
	 */
	/**
	 *将指定值设置为当前属性值。
	 *@param propertyName要设置值的属性的名称
	 *（可以是嵌套路径和/或索引/映射属性）
	 *@param value新值
	 *如果没有此类属性或
	 *如果属性不可写
	 *如果属性有效但
	 *访问器方法失败或发生类型不匹配
	 */
	void setPropertyValue(String propertyName, @Nullable Object value) throws BeansException;

	/**
	 * Set the specified value as current property value.
	 * @param pv an object containing the new property value
	 * @throws InvalidPropertyException if there is no such property or
	 * if the property isn't writable
	 * @throws PropertyAccessException if the property was valid but the
	 * accessor method failed or a type mismatch occurred
	 */
	/**
	 *将指定值设置为当前属性值。
	 *@param pv包含新属性值的对象
	 *如果没有此类属性或
	 *如果属性不可写
	 *如果属性有效但
	 *访问器方法失败或发生类型不匹配
	 */
	void setPropertyValue(PropertyValue pv) throws BeansException;

	/**
	 * Perform a batch update from a Map.
	 * <p>Bulk updates from PropertyValues are more powerful: This method is
	 * provided for convenience. Behavior will be identical to that of
	 * the {@link #setPropertyValues(PropertyValues)} method.
	 * @param map a Map to take properties from. Contains property value objects,
	 * keyed by property name
	 * @throws InvalidPropertyException if there is no such property or
	 * if the property isn't writable
	 * @throws PropertyBatchUpdateException if one or more PropertyAccessExceptions
	 * occurred for specific properties during the batch update. This exception bundles
	 * all individual PropertyAccessExceptions. All other properties will have been
	 * successfully updated.
	 */
	/**
	 *从地图执行批更新。
	 *＜p＞PropertyValues的批量更新功能更强大：此方法是
	 *提供方便。行为将与
	 *｛@link#setPropertyValues（PropertyValues）｝方法。
	 *@param映射要从中获取财产的map。包含属性值对象，
	 *按属性名称键入
	 *如果没有此类属性或
	 *如果属性不可写
	 *如果有一个或多个PropertyAccessExceptions，@throws PropertyBatchUpdateException
	 *在批更新期间，特定财产发生错误。此异常捆绑
	 *所有单独的PropertyAccessExceptions。所有其他财产
	 *已成功更新。
	 */
	void setPropertyValues(Map<?, ?> map) throws BeansException;

	/**
	 * The preferred way to perform a batch update.
	 * <p>Note that performing a batch update differs from performing a single update,
	 * in that an implementation of this class will continue to update properties
	 * if a <b>recoverable</b> error (such as a type mismatch, but <b>not</b> an
	 * invalid field name or the like) is encountered, throwing a
	 * {@link PropertyBatchUpdateException} containing all the individual errors.
	 * This exception can be examined later to see all binding errors.
	 * Properties that were successfully updated remain changed.
	 * <p>Does not allow unknown fields or invalid fields.
	 * @param pvs a PropertyValues to set on the target object
	 * @throws InvalidPropertyException if there is no such property or
	 * if the property isn't writable
	 * @throws PropertyBatchUpdateException if one or more PropertyAccessExceptions
	 * occurred for specific properties during the batch update. This exception bundles
	 * all individual PropertyAccessExceptions. All other properties will have been
	 * successfully updated.
	 * @see #setPropertyValues(PropertyValues, boolean, boolean)
	 */
	/**
	 *执行批处理更新的首选方式。
	 *＜p＞注意，执行批量更新不同于执行单个更新，
	 *在这种情况下，这个类的实现将继续更新财产
	 *如果<b>可恢复的</b>错误（例如类型不匹配，但<b>不是</b>）
	 *无效的字段名等），引发
	 *｛@link PropertyBatchUpdateException｝包含所有单个错误。
	 *稍后可以检查此异常以查看所有绑定错误。
	 *成功更新的财产保持更改。
	 *＜p＞不允许未知字段或无效字段。
	 *@param pvs要在目标对象上设置的PropertyValues
	 *如果没有此类属性或
	 *如果属性不可写
	 *如果有一个或多个PropertyAccessExceptions，@throws PropertyBatchUpdateException
	 *在批更新期间，特定财产发生错误。此异常捆绑
	 *所有单独的PropertyAccessExceptions。所有其他财产
	 *已成功更新。
	 *@see#setPropertyValues（PropertyValues、boolean、boolean）
	 */
	void setPropertyValues(PropertyValues pvs) throws BeansException;

	/**
	 * Perform a batch update with more control over behavior.
	 * <p>Note that performing a batch update differs from performing a single update,
	 * in that an implementation of this class will continue to update properties
	 * if a <b>recoverable</b> error (such as a type mismatch, but <b>not</b> an
	 * invalid field name or the like) is encountered, throwing a
	 * {@link PropertyBatchUpdateException} containing all the individual errors.
	 * This exception can be examined later to see all binding errors.
	 * Properties that were successfully updated remain changed.
	 * @param pvs a PropertyValues to set on the target object
	 * @param ignoreUnknown should we ignore unknown properties (not found in the bean)
	 * @throws InvalidPropertyException if there is no such property or
	 * if the property isn't writable
	 * @throws PropertyBatchUpdateException if one or more PropertyAccessExceptions
	 * occurred for specific properties during the batch update. This exception bundles
	 * all individual PropertyAccessExceptions. All other properties will have been
	 * successfully updated.
	 * @see #setPropertyValues(PropertyValues, boolean, boolean)
	 */
	/**
	 *执行批处理更新，以更好地控制行为。
	 *＜p＞注意，执行批量更新不同于执行单个更新，
	 *在这种情况下，这个类的实现将继续更新财产
	 *如果<b>可恢复的</b>错误（例如类型不匹配，但<b>不是</b>）
	 *无效的字段名等），引发
	 *｛@link PropertyBatchUpdateException｝包含所有单个错误。
	 *稍后可以检查此异常以查看所有绑定错误。
	 *成功更新的财产保持更改。
	 *@param pvs要在目标对象上设置的PropertyValues
	 *@param ignoreUnknown我们应该忽略未知的财产（在bean中找不到）
	 *如果没有此类属性或
	 *如果属性不可写
	 *如果有一个或多个PropertyAccessExceptions，@throws PropertyBatchUpdateException
	 *在批更新期间，特定财产发生错误。此异常捆绑
	 *所有单独的PropertyAccessExceptions。所有其他财产
	 *已成功更新。
	 *@see#setPropertyValues（PropertyValues、boolean、boolean）
	 */
	void setPropertyValues(PropertyValues pvs, boolean ignoreUnknown)
			throws BeansException;

	/**
	 * Perform a batch update with full control over behavior.
	 * <p>Note that performing a batch update differs from performing a single update,
	 * in that an implementation of this class will continue to update properties
	 * if a <b>recoverable</b> error (such as a type mismatch, but <b>not</b> an
	 * invalid field name or the like) is encountered, throwing a
	 * {@link PropertyBatchUpdateException} containing all the individual errors.
	 * This exception can be examined later to see all binding errors.
	 * Properties that were successfully updated remain changed.
	 * @param pvs a PropertyValues to set on the target object
	 * @param ignoreUnknown should we ignore unknown properties (not found in the bean)
	 * @param ignoreInvalid should we ignore invalid properties (found but not accessible)
	 * @throws InvalidPropertyException if there is no such property or
	 * if the property isn't writable
	 * @throws PropertyBatchUpdateException if one or more PropertyAccessExceptions
	 * occurred for specific properties during the batch update. This exception bundles
	 * all individual PropertyAccessExceptions. All other properties will have been
	 * successfully updated.
	 */
	/**
	 *在完全控制行为的情况下执行批处理更新。
	 *＜p＞注意，执行批量更新不同于执行单个更新，
	 *在这种情况下，这个类的实现将继续更新财产
	 *如果<b>可恢复的</b>错误（例如类型不匹配，但<b>不是</b>）
	 *无效的字段名等），引发
	 *｛@link PropertyBatchUpdateException｝包含所有单个错误。
	 *稍后可以检查此异常以查看所有绑定错误。
	 *成功更新的财产保持更改。
	 *@param pvs要在目标对象上设置的PropertyValues
	 *@param ignoreUnknown我们应该忽略未知的财产（在bean中找不到）
	 *@param ignoreInvalid应忽略无效的财产（已找到但无法访问）
	 *如果没有此类属性或
	 *如果属性不可写
	 *如果有一个或多个PropertyAccessExceptions，@throws PropertyBatchUpdateException
	 *在批更新期间，特定财产发生错误。此异常捆绑
	 *所有单独的PropertyAccessExceptions。所有其他财产
	 *已成功更新。
	 */
	void setPropertyValues(PropertyValues pvs, boolean ignoreUnknown, boolean ignoreInvalid)
			throws BeansException;

}
